package com.room.search.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.room.search.domain.enumeration.BkRoomTypeEnum;
import com.room.search.domain.enumeration.RoomRentMethodEnum;

import javax.persistence.*;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.*;

/**
 * 房屋详情
 */
@Entity
@Table(name = "room_goods")
@org.springframework.data.elasticsearch.annotations.Document(indexName = "room_goods")
public class RoomGoods implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 房屋所属类型
     */
    @Column(name = "bk_room_type")
    @Enumerated(EnumType.STRING)
    private BkRoomTypeEnum bkRoomType;

    /**
     * 贝壳编号
     */
    @Size(max = 32)
    @Column(name = "bk_no", length = 32)
    private String bkNo;

    /**
     * title
     */
    @Size(max = 1024)
    @Column(name = "title", length = 1024)
    private String title;

    /**
     * 定价
     */
    @Size(max = 32)
    @Column(name = "oldprice", length = 32)
    private String oldprice;


    /**
     * 被关注情况
     */
    @Size(max = 8)
    @Column(name = "focus_no", length = 8)
    private String focusNo;


    /**
     * 核心卖点
     */
    @Lob
    @Column(name = "room_sell_point",columnDefinition = "text")
    private String roomSellPoint;

    /**
     * 小区介绍
     */
    @Lob
    @Column(name = "community_introduction", columnDefinition = "text")
    private String communityIntroduction;

    /**
     * 户型介绍
     */
    @Lob
    @Column(name = "room_introduction", columnDefinition = "text")
    private String roomIntroduction;

    /**
     * 周边配套
     */
    @Lob
    @Column(name = "surrounding_facilities", columnDefinition = "text")
    private String surroundingFacilities;

    /**
     * 交通出行
     */
    @Lob
    @Column(name = "transportation", columnDefinition = "text")
    private String transportation;

    /**
     * 所属经纪人
     */
    @Column(name = "room_broker")
    private Long roomBroker;

    /**
     * 是否已经被售出
     */
    @Column(name = "selling")
    private Boolean selling;

    /**
     * 经度
     */
    @Column(name = "longitude")
    private String longitude;
    /**
     * 纬度
     */
    @Column(name = "latitude")
    private String latitude;

    /**
     * 具体位置
     */
    @Column(name = "address")
    private String address;

    /**
     * 省份
     */
    @Column(name = "province")
    private String province;
    /**
     * 市区
     */
    @Column(name = "city")
    private String city;
    /**
     * 区县
     */
    @Column(name = "district")
    private String district;

    /**
     * 每平米价格
     */
    @Column(name = "area_price")
    private String areaPrice;

    /**
     * 创建时间
     */
    @Column(name = "created_date")
    private Date createdDate;

    /**
     * 上架时间
     */
    @Column(name = "up_date")
    private Date upDate;

    /**
     * 看房时间
     */
    @Column(name = "contact_date")
    private Date contactDate;

    /**
     * 租房方式
     */
    @Column(name = "rent_method")
    @Enumerated(EnumType.STRING)
    private RoomRentMethodEnum rentMethod;

    /**
     * 户型图Fast_dfs的路径
     */
    @Column(name = "floor_plan")
    private String floorPlan;

    @JsonIgnore
    @ManyToMany
    @JoinTable(
        name = "room_goods_broker",
        joinColumns = {@JoinColumn(name = "goods_id", referencedColumnName = "id")},
        inverseJoinColumns = {@JoinColumn(name = "broker_id", referencedColumnName = "id")}
    )
    private Set<RoomBroker> roomBrokers = new HashSet<>();

    @JsonIgnore
    @OneToMany
    private List<RoomListingFeature> roomFeatureIds = new ArrayList<>();

    @OneToOne
    private RoomBasicProperty roomBasic;

    @OneToOne
    private RoomTransactionProperty roomTransaction;

    @ManyToOne
    private RoomCommunity community;

    @OneToOne
    private RoomSupportingFacilities supporting;

    @OneToOne
    private RoomRentBasic rentBasic;

    @OneToMany(mappedBy = "goods")
    @JsonIgnore
    private List<RoomFile> files;

    @Column(name = "shelves")
    private Boolean shelves;

    @ManyToMany
    @JsonIgnore
    @JoinTable(
        name = "room_goods_user",
        joinColumns = {@JoinColumn(name = "goods_id", referencedColumnName = "id")},
        inverseJoinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")}
    )
    private List<RoomUser> roomUsers;


    // jhipster-needle-entity-add-field - JHipster will add fields here


    public List<RoomUser> getRoomUsers() {
        return roomUsers;
    }

    public RoomGoods setRoomUsers(List<RoomUser> roomUsers) {
        this.roomUsers = roomUsers;
        return this;
    }

    public Boolean getShelves() {
        return shelves;
    }

    public RoomGoods setShelves(Boolean shelves) {
        this.shelves = shelves;
        return this;
    }

    public Long getId() {
        return id;
    }

    public RoomGoods setId(Long id) {
        this.id = id;
        return this;
    }

    public BkRoomTypeEnum getBkRoomType() {
        return bkRoomType;
    }

    public RoomGoods setBkRoomType(BkRoomTypeEnum bkRoomType) {
        this.bkRoomType = bkRoomType;
        return this;
    }

    public String getBkNo() {
        return bkNo;
    }

    public RoomGoods setBkNo(String bkNo) {
        this.bkNo = bkNo;
        return this;
    }

    public String getTitle() {
        return title;
    }

    public RoomGoods setTitle(String title) {
        this.title = title;
        return this;
    }

    public String getOldprice() {
        return oldprice;
    }

    public RoomGoods setOldprice(String oldprice) {
        this.oldprice = oldprice;
        return this;
    }

    public String getFocusNo() {
        return focusNo;
    }

    public RoomGoods setFocusNo(String focusNo) {
        this.focusNo = focusNo;
        return this;
    }

    public String getRoomSellPoint() {
        return roomSellPoint;
    }

    public RoomGoods setRoomSellPoint(String roomSellPoint) {
        this.roomSellPoint = roomSellPoint;
        return this;
    }

    public String getCommunityIntroduction() {
        return communityIntroduction;
    }

    public RoomGoods setCommunityIntroduction(String communityIntroduction) {
        this.communityIntroduction = communityIntroduction;
        return this;
    }

    public String getRoomIntroduction() {
        return roomIntroduction;
    }

    public RoomGoods setRoomIntroduction(String roomIntroduction) {
        this.roomIntroduction = roomIntroduction;
        return this;
    }

    public String getSurroundingFacilities() {
        return surroundingFacilities;
    }

    public RoomGoods setSurroundingFacilities(String surroundingFacilities) {
        this.surroundingFacilities = surroundingFacilities;
        return this;
    }

    public String getTransportation() {
        return transportation;
    }

    public RoomGoods setTransportation(String transportation) {
        this.transportation = transportation;
        return this;
    }

    public Long getRoomBroker() {
        return roomBroker;
    }

    public RoomGoods setRoomBroker(Long roomBroker) {
        this.roomBroker = roomBroker;
        return this;
    }

    public Boolean getSelling() {
        return selling;
    }

    public RoomGoods setSelling(Boolean selling) {
        this.selling = selling;
        return this;
    }

    public String getLongitude() {
        return longitude;
    }

    public RoomGoods setLongitude(String longitude) {
        this.longitude = longitude;
        return this;
    }

    public String getLatitude() {
        return latitude;
    }

    public RoomGoods setLatitude(String latitude) {
        this.latitude = latitude;
        return this;
    }

    public String getAddress() {
        return address;
    }

    public RoomGoods setAddress(String address) {
        this.address = address;
        return this;
    }

    public String getProvince() {
        return province;
    }

    public RoomGoods setProvince(String province) {
        this.province = province;
        return this;
    }

    public String getCity() {
        return city;
    }

    public RoomGoods setCity(String city) {
        this.city = city;
        return this;
    }

    public String getDistrict() {
        return district;
    }

    public RoomGoods setDistrict(String district) {
        this.district = district;
        return this;
    }

    public String getAreaPrice() {
        return areaPrice;
    }

    public void setAreaPrice(String areaPrice) {
        this.areaPrice = areaPrice;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public RoomGoods setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
        return this;
    }

    public Date getUpDate() {
        return upDate;
    }

    public RoomGoods setUpDate(Date upDate) {
        this.upDate = upDate;
        return this;
    }

    public Date getContactDate() {
        return contactDate;
    }

    public RoomGoods setContactDate(Date contactDate) {
        this.contactDate = contactDate;
        return this;
    }

    public RoomRentMethodEnum getRentMethod() {
        return rentMethod;
    }

    public RoomGoods setRentMethod(RoomRentMethodEnum rentMethod) {
        this.rentMethod = rentMethod;
        return this;
    }

    public String getFloorPlan() {
        return floorPlan;
    }

    public RoomGoods setFloorPlan(String floorPlan) {
        this.floorPlan = floorPlan;
        return this;
    }

    public Set<RoomBroker> getRoomBrokers() {
        return roomBrokers;
    }

    public RoomGoods setRoomBrokers(Set<RoomBroker> roomBrokers) {
        this.roomBrokers = roomBrokers;
        return this;
    }

    public List<RoomListingFeature> getRoomFeatureIds() {
        return roomFeatureIds;
    }

    public RoomGoods setRoomFeatureIds(List<RoomListingFeature> roomFeatureIds) {
        this.roomFeatureIds = roomFeatureIds;
        return this;
    }

    public RoomBasicProperty getRoomBasic() {
        return roomBasic;
    }

    public RoomGoods setRoomBasic(RoomBasicProperty roomBasic) {
        this.roomBasic = roomBasic;
        return this;
    }

    public RoomTransactionProperty getRoomTransaction() {
        return roomTransaction;
    }

    public RoomGoods setRoomTransaction(RoomTransactionProperty roomTransaction) {
        this.roomTransaction = roomTransaction;
        return this;
    }



    public RoomCommunity getCommunity() {
        return community;
    }

    public RoomGoods setCommunity(RoomCommunity community) {
        this.community = community;
        return this;
    }

    public RoomSupportingFacilities getSupporting() {
        return supporting;
    }

    public RoomGoods setSupporting(RoomSupportingFacilities supporting) {
        this.supporting = supporting;
        return this;
    }

    public RoomRentBasic getRentBasic() {
        return rentBasic;
    }

    public RoomGoods setRentBasic(RoomRentBasic rentBasic) {
        this.rentBasic = rentBasic;
        return this;
    }

    public List<RoomFile> getFiles() {
        return files;
    }

    public void setFiles(List<RoomFile> files) {
        this.files = files;
    }

    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof RoomGoods)) {
            return false;
        }
        return id != null && id.equals(((RoomGoods) o).id);
    }

    @Override
    public int hashCode() {
        // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
        return getClass().hashCode();
    }

    @Override
    public String toString() {
        return "RoomGoods{" +
            "id=" + id +
            ", bkRoomType=" + bkRoomType +
            ", bkNo='" + bkNo + '\'' +
            ", title='" + title + '\'' +
            ", oldprice='" + oldprice + '\'' +
            ", focusNo='" + focusNo + '\'' +
            ", roomSellPoint='" + roomSellPoint + '\'' +
            ", communityIntroduction='" + communityIntroduction + '\'' +
            ", roomIntroduction='" + roomIntroduction + '\'' +
            ", surroundingFacilities='" + surroundingFacilities + '\'' +
            ", transportation='" + transportation + '\'' +
            ", roomBroker=" + roomBroker +
            ", selling=" + selling +
            ", longitude='" + longitude + '\'' +
            ", latitude='" + latitude + '\'' +
            ", address='" + address + '\'' +
            ", province='" + province + '\'' +
            ", city='" + city + '\'' +
            ", district='" + district + '\'' +
            ", roomBrokers=" + roomBrokers +
            ", roomFeatureIds=" + roomFeatureIds +
            ", roomBasic=" + roomBasic +
            ", roomTransaction=" + roomTransaction +
            ", community=" + community +
            ", supporting=" + supporting +
            '}';
    }
}
